#include "spdlog/spdlog.h"
#include "wal.h"
#include <exception>
#include <vector>

using spdlog::info;

int main(void) {
  try {
    wal::WAL wal("example.wal");

    std::vector<std::string> ss;
    for (int i = 0; i < 5; i++) {
      std::string s = "hello world:" + std::to_string(i);
      ss.emplace_back(s);
    }
    for (auto const &s : ss) {
      wal::bytes data(s.begin(), s.end());
      wal.write(data);
    }
    auto it = wal.iter();
    for (auto bs = it.next(); bs.has_value(); bs = it.next()) {
      info("sz: {}", bs->size());
      info("get value: {}", std::string(bs->begin(), bs->end()));
    }
  } catch (std::exception &e) {
		std::cerr << "error occur: " << e.what() << std::endl;
  }
  return 0;
}
